﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Practices.Unity;

namespace Skynet.MVCWebSite
{
    public class UnityControllerFactory : System.Web.Mvc.DefaultControllerFactory
    {
        private  IUnityContainer container;
        public UnityControllerFactory(IUnityContainer container): base()
        {
            this.container = container;
        }
        protected override System.Web.Mvc.IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
        {
            if (controllerType != null)
                return this.container.Resolve(controllerType) as System.Web.Mvc.IController;
            else
                return null;
        }
    }
}